package com.example.database_1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;


public class ActivityAdd extends Activity implements android.view.View.OnClickListener {
	Button btnOk, btnCancel;
	EditText etName, etTel, etEmail;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.d("myLogs", "--- CreateView ---");
		setContentView(R.layout.activity_add);
		etName = (EditText) findViewById(R.id.etName);
		btnOk = (Button) findViewById(R.id.btnOk);
		btnOk.setOnClickListener(this);
		btnCancel = (Button) findViewById(R.id.btnCancel);
		btnCancel.setOnClickListener(this);
		
        
	}
	protected void onDestroy() {
	super.onDestroy();
	}
	
	@Override
	public void onClick(View v) {
		Log.d("myLogs", "--- Adding ---");
		switch (v.getId()) {
		case R.id.btnOk:
			Intent intent = new Intent();
			intent.putExtra("name", etName.getText().toString());
			Log.d("myLogs", "--- 3 ---");
		    setResult(RESULT_OK, intent);
		    finish();
			//startActivity(intent);
			break;
		default:
			break;
		case R.id.btnCancel:
			Intent inten = new Intent(this, MainActivity.class);
			startActivity(inten);
			break;
		}
	}
	
	//public void onClick(View v) {
		//Log.d("myLogs", "--- Adding ---");
		//DataBase field = new DataBase();
		
		//switch (v.getId()) {
		//case R.id.btnOk:
			//field.WriteToDB(etName, etTel, etEmail);
			//setResult(RESULT_OK, getIntent());
			//break;
			
		//case R.id.btnCancel:
			//break;
		//}
	//}

}
